//格式化时间(年月日)
function tools_getdate(object){
    if(object){
        const year = object.getFullYear();
        const month = String(object.getMonth() + 1).padStart(2, '0');
        const day = String(object.getDate()).padStart(2, '0');
        return year+"-"+month+"-"+day;
    }
    return "";
  }
  //格式化时间(年月日时分秒)
  function tools_getdatetime(object){
    if(object){
        const year = object.getFullYear();
        const month = String(object.getMonth() + 1).padStart(2, '0');
        const day = String(object.getDate()).padStart(2, '0');
        const hours = String(object.getHours()).padStart(2, '0');
        const minutes = String(object.getMinutes()).padStart(2, '0');
        const seconds = String(object.getSeconds()).padStart(2, '0');
        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    }
    return "";
  }
  //生成uuid
  function tools_uuid() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    var uuid = s.join("");
    return uuid;
  }
  //检查字符串是否包含数组中的所有字符串，str字符串，substrings字符串数组
  function tools_jczfc(str,substrings) {
    return substrings.every(substring => str.includes(substring));
  }
  //百分比转小数
  function tools_percentageToDecimal(percentage) {
    let decimal = parseFloat(percentage.slice(0, -1)) / 100;
    return decimal;
  }
  //生成指定长度随机字符串
  function tools_generateRandomPassword(length) {
    const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    let password = '';
    for (let i = 0; i < length; i++) {
      password += characters.charAt(Math.floor(Math.random() * characters.length));
    }
    return password;
  }
  //数值转大写
function tools_functiondigitUppercase(price) {
    const fraction = ["角", "分"];
    const digit = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
    const unit = [
      ["元", "万", "亿"],
      ["", "拾", "佰", "仟"],
    ];
    let num = Math.abs(price);
    let s = "";
    fraction.forEach((item, index) => {
      s += (digit[Math.floor(num * 10 * 10 ** index) % 10] + item).replace(
        /零./,
        ""
      );
    });
    s = s || "整";
    num = Math.floor(num);
    for (let i = 0; i < unit[0].length && num > 0; i += 1) {
      let p = "";
      for (let j = 0; j < unit[1].length && num > 0; j += 1) {
        p = digit[num % 10] + unit[1][j] + p;
        num = Math.floor(num / 10);
      }
      s = p.replace(/(零.)*零$/, "").replace(/^$/, "零") + unit[0][i] + s;
    }
    return s.replace(/(零.)*零元/, "元").replace(/(零.)+/g, "零").replace(/^整$/, "零元整");
}
//两个日期之间的天数差
function tools_daysBetween(date1, date2) {
    const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数
    const firstTime = date1.getTime(); // 将日期转换为时间戳
    const secondTime = date2.getTime();
    return Math.round(Math.abs((firstTime - secondTime) / oneDay)); // 计算天数并四舍五入
}
//判断字符串是否有字母
function tools_containsLetter(str) {
    return /[A-Za-z]/.test(str);
}
//判断是否有汉字
function tools_isContainChinese(str) {
    var regex = /[\u4e00-\u9fa5]/;
    return regex.test(str);
}